package main

import (
	"fmt"
	"sync"
	"time"
)

type any = interface{}
type hash = map[string]any
type hash2 = map[string]int
type KVStore struct {
	data hash
}

var mu sync.Mutex

func (kv *KVStore) Save(key string, value any) {
	mu.Lock()
	defer mu.Unlock()

	kv.data[key] = value
}
func (kv *KVStore) Load(key string) any {
	mu.Lock()
	defer mu.Unlock()

	if v, ok := kv.data[key]; ok {
		return v
	}
	return nil
}

func main() {

	kv := &KVStore{data: hash{}}
	var v any
	if time.Now().Unix()%2 == 0 {
		v = hash{"a": "hahhaha"}
	} else {
		v = hash2{"a": 123}
	}
	kv.Save("randkey", hash{"key": v})

	fmt.Printf("randkey: %#v\n", kv.Load("randkey"))
}
